﻿# Observable class - used to allow custom event binding
# used to be inherited by others
class window.Observable
    constructor:()->
        @events = []
    bind : (type, fnc) ->
        if not @events[type]
            @events[type] = []        
        @events[type].push(fnc);
    unbind : (type, fnc) ->
        if @events[type]
            @events[type].each( (elem, index, arr)->
                if elem is fnc
                    @events[type].splice(index,1);
            )
    notify : (type, args)->
        x = true
        if @events[type]
            @events[type].each( (elem, index, arr)->
                x = x && elem(args)
            )    
        x
